package com.ding.mongodb.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@Document
public class User{
	@Id
	private String username;
	@Field("pwd")
	private String password;
	private int enabled=1;
	private List<Authority> authorities=new ArrayList<>();

	public User(String username,String password) {
		this.password=password;
		this.username=username;
	}

	public void addAuthority(String authority) {
		Authority auth = new Authority(this, authority);
		authorities.add(auth);
	}

	public List<Authority> getAuthorities() {
		return authorities;
	}

	public String getPassword() {
		return password;
	}
}
